package com.gzdh.dishrecognition.ui.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.gzdh.dishrecognition.R;
import com.gzdh.dishrecognition.model.WeekMenuBakModel;

import java.util.ArrayList;
import java.util.List;

public class DownFkAdapter extends RecyclerView.Adapter<DownFkAdapter.ViewHolder> {

    private Context mcontext;

    private List<String> list;


    private int pot = 0;

    private int listSize = 20;

    public DownFkAdapter(Context context) {
        mcontext = context;
        this.list = new ArrayList<>();


    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_string_gridview_item1, parent, false);
        return new ViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.nameTv.setText(list.get(position));
        holder.nameTv.setTextColor(Color.WHITE);
        holder.nameTv.setTextSize(15);
        holder.mainLinear.setPadding(0, 0, 0, 0);
    }


    @Override
    public int getItemCount() {
        return list.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView nameTv;
        LinearLayout mainLinear;

        ViewHolder(View item) {
            super(item);
            nameTv = item.findViewById(R.id.nameTv);
            mainLinear = item.findViewById(R.id.mainLinear);
        }
    }

    private long lastShow = 0;


    private long lastTime = 0;

    public void showLine(String str) {
        list.add(str);
        if (list.size() > 25) {
            list.remove(0);
        }
        notifyDataSetChanged();

    }


}
